package com.example.llademo.entity;

import com.example.llademo.util.DateUtil;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.format.annotation.DateTimeFormat;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.math.BigDecimal;
import java.util.Date;

/**
 * @author zhangqi
 * @date 2024/4/1
 * @time 15:10
 * @description 卫星轨迹
 */
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
@Slf4j
public class LLAPosition {

    //Time (UTCG) 接收时间
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date captureTime;
    //Lat (deg)
    private BigDecimal lat;
    //Lon (deg)
    private BigDecimal lon;
    //Alt (km)
    private BigDecimal alt;
    //Lat Rate (deg/sec)
    private BigDecimal latRate;
    //Lon Rate (deg/sec)
    private BigDecimal lonRate;
    //Alt Rate (km/sec)
    private BigDecimal altRate;

    public static LLAPosition getLLA(String[] splitLine){
        return LLAPosition.builder()
                .captureTime(DateUtil.convertLlaDate(splitLine[0]))
                .lat(new BigDecimal(splitLine[1]))
                .lon(new BigDecimal(splitLine[2]))
                .alt(new BigDecimal(splitLine[3]))
                .latRate(new BigDecimal(splitLine[4]))
                .lonRate(new BigDecimal(splitLine[5]))
                .altRate(new BigDecimal(splitLine[6]))
                .build();
    }

}
